package cmd

import (
	"fmt"

	"github.com/louloulin/dataflare/pkg/workflow/cmd"
	"github.com/spf13/cobra"
)

// workflowRunLocalCmd represents the workflow run-local command
var workflowRunLocalCmd = &cobra.Command{
	Use:   "run-local",
	Short: "Run a workflow locally",
	Long:  `Run a DataFlare workflow locally without a server.`,
	RunE: func(cmd *cobra.Command, args []string) error {
		// Check if workflow file is provided
		if workflowFile == "" {
			return fmt.Errorf("workflow file is required")
		}

		// Run workflow
		return cmd.RunWorkflow(workflowFile, "actor")
	},
}

func init() {
	workflowCmd.AddCommand(workflowRunLocalCmd)

	// Add flags
	workflowRunLocalCmd.Flags().StringVarP(&workflowFile, "file", "f", "", "Workflow definition file")
	workflowRunLocalCmd.MarkFlagRequired("file")
}
